#include<iostream>

using namespace std;

const int N = 25;
int a[N][N];

int main()
{
	int n, m, k; cin >> n >> m >> k;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			cin >> a[i][j];
		}
	}
	long long sum = 0;
	while (k--)
	{
		long long ad_x = 0; int key_x = 0;
		for (int i = 1; i <= n; i++)
		{
			long long s1 = 0;
			for (int j = 1; j <= m; j++)
			{
				s1 += a[i][j];
			}
			if (s1 > ad_x)
			{
				ad_x = s1;
				key_x = i;
			}
		}
		long long ad_y = 0; int key_y = 0;
		for (int j = 1; j <= m; j++)
		{
			long long s2 = 0;
			for (int i = 1; i <= n; i++)
			{
				s2 += a[i][j];
			}
			if (s2 > ad_y)
			{
				ad_y = s2;
				key_y = j;
			}
		}
		if (ad_x > ad_y)
		{
				for (int j = 1; j <= m; j++)
				{
					a[key_x][j] = 0;
				}
				sum += ad_x;
		}
		else
		{
			for (int i = 1; i <= n; i++)
			{
				a[i][key_y] = 0;
			}
			sum += ad_y;
		}
	}
	cout << sum;
	return 0;
}
